
//
//  HJDHospitalViewController.m
//  JYHospital
//
//  Created by 胡金东 on 16/4/29.
//  Copyright © 2016年 胡金东. All rights reserved.
//

#import "HJDHospitalViewController.h"
#import "HJDDetailViewController.h"
#import "RESideMenu.h"
//#import "HJDRootViewController.h"
#import "HJDNavigationController.h"


@interface HJDHospitalViewController ()<UIScrollViewDelegate>

@property (nonatomic,strong) UIScrollView * scroll;

//
@property (nonatomic,strong) UIView * nameView;
//地址view
@property (nonatomic,strong) UIView * addressView;
//简介view
@property (nonatomic,strong) UIView * introductionView;
@property (nonatomic,strong) UIButton *phoneBtn;


@end

@implementation HJDHospitalViewController

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = YES;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];

    [self setUpName];
    [self setUpAddress];
    [self setUpIntroduction];
    [self setUpDedails];
    
    
    
    
    [self setUpNavigation];
    
    
}

-(void)setUpNavigation
{
    CGFloat leftX = HJDHorizontalMargin;
    CGFloat leftY = 30 - 10;
    CGFloat leftW = 34;
    CGFloat leftH = 34;
    UIButton *navleftBtn = [[UIButton alloc]initWithFrame:CGRectMake(leftX, leftY, leftW, leftH)];
    [navleftBtn setBackgroundImage:[UIImage imageNamed:@"矢量智能对象侧"] forState:UIControlStateNormal];
    [navleftBtn addTarget:self action:@selector(MyCenterClick) forControlEvents:UIControlEventTouchUpInside];
    
    [self.scroll addSubview:navleftBtn];
    
    
}

-(void)MyCenterClick
{
    [self.sideMenuViewController presentLeftMenuViewController];

}
    


-(void)setUpName
{
    self.scroll = [[UIScrollView alloc]initWithFrame:[UIScreen mainScreen].bounds];
    self.scroll.delegate =self;
//    自动适应
    self.automaticallyAdjustsScrollViewInsets = YES;
    self.scroll.showsHorizontalScrollIndicator = NO;
    self.scroll.showsVerticalScrollIndicator = YES;
    self.scroll.contentSize = CGSizeMake(HJDWidth, 767);
    [self.view addSubview:self.scroll];
    
    CGFloat imageX = 0;
    CGFloat imageY = 0;
    CGFloat imageW = HJDWidth;
    CGFloat imageH = 150;
    UIImageView * imageView = [[UIImageView alloc]initWithFrame:CGRectMake(imageX, imageY, imageW, imageH)];
    imageView.image = [UIImage imageNamed:@"5"];
    [self.scroll addSubview:imageView];
    
    
    CGFloat lblNameX = HJDVerticalMargin/2;
    CGFloat lblNameY = CGRectGetMaxY(imageView.frame) + HJDVerticalMargin/2;
    CGFloat lblNameW = HJDWidth;
    CGFloat lblNameH = 40;
    UILabel *lblName =[[UILabel alloc]initWithFrame:CGRectMake(lblNameX, lblNameY, lblNameW, lblNameH)];
    lblName.text = @"常州武进红房子医院";
    lblName.font = [UIFont boldSystemFontOfSize:24];
    lblName.textColor = [UIColor getColorWithHexNumber:@"323232"];
    [self.scroll addSubview:lblName];
    
    CGFloat lblTypeX = HJDVerticalMargin/2;
    CGFloat lblTypeY = CGRectGetMaxY(lblName.frame)-5;
    CGFloat lblTypeW = HJDWidth;
    CGFloat lblTypeH = 25;
    UILabel *lblType = [[UILabel alloc]initWithFrame:CGRectMake(lblTypeX, lblTypeY, lblTypeW, lblTypeH)];
    lblType.text = @"医院类型：妇产科";
    lblType.textColor = [UIColor getColorWithHexNumber:@"848484"];
    lblType.font = [UIFont systemFontOfSize:15];
    [self.scroll addSubview:lblType];
    
    CGFloat nameViewX = 0;
    CGFloat nameViewY = CGRectGetMaxY(lblType.frame)+HJDVerticalMargin;
    CGFloat nameViewW = HJDWidth;
    CGFloat nameViewH = 20;
    self.nameView = [[UIView alloc]initWithFrame:CGRectMake(nameViewX, nameViewY, nameViewW, nameViewH)];
    self.nameView.backgroundColor =[UIColor getColorWithHexNumber:@"F1F1EE"];
    
    [self.scroll addSubview: self.nameView];
    
}

-(void)setUpAddress
{
//    图标
    CGFloat imageViewX = HJDVerticalMargin/3 ;
    CGFloat imageViewY = CGRectGetMaxY(self.nameView.frame) + HJDVerticalMargin/2 ;
    CGFloat imageViewW = 23/2;
    CGFloat imageViewH = 29/2;
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(imageViewX, imageViewY, imageViewW, imageViewH)];
    imageView.image = [UIImage imageNamed:@"地点"];
    [self.scroll  addSubview:imageView];
    
    CGFloat lbladdressX = HJDVerticalMargin + 1;
    CGFloat lbladdressY = CGRectGetMaxY(imageView.frame) -18;
    CGFloat lbladdressW = HJDWidth - imageViewX -imageViewW;
    CGFloat lbladdressH = 25;
    UILabel *lbladdress = [[UILabel alloc]initWithFrame:CGRectMake(lbladdressX, lbladdressY, lbladdressW, lbladdressH)];
    lbladdress.text = @"常州市武进区湖塘镇常武北路2号(兰新大厦北侧)";
    lbladdress.textColor = [UIColor getColorWithHexNumber:@"323232"];
    lbladdress.font = [UIFont systemFontOfSize:14];
  
    [self.scroll addSubview:lbladdress];
    
    CGFloat phoneImageX = HJDVerticalMargin/3 ;
    CGFloat phoneImageY = CGRectGetMaxY(lbladdress.frame) + HJDVerticalMargin/2 ;
    CGFloat phoneImageW = 13;
    CGFloat phoneImageH = 13;
    UIImageView *phoneImageView = [[UIImageView alloc]initWithFrame:CGRectMake(phoneImageX, phoneImageY, phoneImageW, phoneImageH)];
    phoneImageView.image = [UIImage imageNamed:@"电话"];
    [self.scroll  addSubview:phoneImageView];
    
    CGFloat phoneBtnX = HJDVerticalMargin -4;
    CGFloat phoneBtnY = CGRectGetMaxY(lbladdress.frame) + 5 ;
    CGFloat phoneBtnW = 120;
    CGFloat phoneBtnH = 25;
  self.phoneBtn = [[UIButton alloc]initWithFrame:CGRectMake(phoneBtnX, phoneBtnY, phoneBtnW, phoneBtnH)];
    [self.phoneBtn setTitle:@"021-50803214" forState:UIControlStateNormal];
    [self.phoneBtn setTitleColor:[UIColor getColorWithHexNumber:@"323232"] forState:UIControlStateNormal];
    self.phoneBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    
   
    [self.phoneBtn addTarget:self action:@selector(phoneBtnClick) forControlEvents:UIControlEventTouchUpInside];
    
   
    [self.scroll addSubview:self.phoneBtn];
    
    CGFloat addressViewX = 0;
    CGFloat addressViewY = CGRectGetMaxY(self.phoneBtn.frame)+HJDVerticalMargin/2;
    CGFloat addressViewW = HJDWidth;
    CGFloat addressViewH = 20;
    self.addressView = [[UIView alloc]initWithFrame:CGRectMake(addressViewX, addressViewY, addressViewW, addressViewH)];
    self.addressView.backgroundColor =[UIColor getColorWithHexNumber:@"F1F1EE"];
    
    [self.scroll addSubview: self.addressView];
    

}

-(void)setUpIntroduction
{
    
    CGFloat titleLblX = HJDVerticalMargin;
    CGFloat titleLblY = CGRectGetMaxY(self.addressView.frame) + HJDVerticalMargin/2;
    CGFloat titleLblW = HJDWidth;
    CGFloat titleLblH = 30;
    UILabel *titleLbl = [[UILabel alloc]initWithFrame:CGRectMake(titleLblX, titleLblY, titleLblW, titleLblH)];
    titleLbl.text = @"医院简介";
    titleLbl.textColor = [UIColor getColorWithHexNumber:@"323232"];
    titleLbl.font = [UIFont systemFontOfSize:15];
    [self.scroll addSubview:titleLbl];
    
    CGFloat btntitleX = HJDVerticalMargin;
    CGFloat btntitleY = CGRectGetMaxY(self.addressView.frame) + HJDVerticalMargin/2;
    CGFloat btntitleW = HJDWidth;
    CGFloat btntitleH = 30;
    UIButton *btntitle = [[UIButton alloc]initWithFrame:CGRectMake(btntitleX, btntitleY, btntitleW, btntitleH)];
    [btntitle addTarget:self action:@selector(btntitleClick) forControlEvents:UIControlEventTouchUpInside];
    [self.scroll addSubview:btntitle];
    
    CGFloat titleviewX = HJDHorizontalMargin ;
    CGFloat titleviewY = CGRectGetMaxY(btntitle.frame);
    CGFloat titleviewW = HJDWidth - HJDHorizontalMargin ;
    CGFloat titleviewH = 1;
    UIView *titleview = [[UIView alloc]initWithFrame:CGRectMake(titleviewX, titleviewY, titleviewW, titleviewH)];
    titleview.backgroundColor = [UIColor getColorWithHexNumber:@"F1F1EE"];
    [self.scroll addSubview:titleview];
    
    CGFloat contentLblX = HJDHorizontalMargin ;
    CGFloat contentLblY = CGRectGetMaxY(titleview.frame)-10;
    CGFloat contentLblW = HJDWidth - HJDHorizontalMargin -10 ;
    CGFloat contentLblH = 80;
    UILabel *contentLbl=[[UILabel alloc]initWithFrame:CGRectMake(contentLblX,contentLblY,contentLblW,contentLblH)];
    [contentLbl setNumberOfLines:0];
    contentLbl.font=[UIFont systemFontOfSize:16];
    contentLbl.text=@"常州红房子医院座落于交通便捷、环境优雅的武进湖塘常武北路，是经医疗卫生行政主管部门批准设立的，功能设置最全、服务品质最高、涉及专科最广的现代化专业妇产科医院。医院自创办以来，以“务实、高效、求精、创新”为院训，“以人为本、求专求强、品牌制胜、永续经营”为经营理念，一贯坚持依法行医、规范行医、文明行医，坚持医疗质量和服务质量至上的原则，在强化医疗安全的基础上切实尊重患者的知情权、选择权和隐私权。";
    contentLbl.font = [UIFont systemFontOfSize:15];
    contentLbl.textColor=[UIColor getColorWithHexNumber:@"848484"];
    [self.scroll addSubview:contentLbl];
   
    CGFloat introductionViewX = 0;
    CGFloat introductionViewY = CGRectGetMaxY(contentLbl.frame)+5;
    CGFloat introductionViewW = HJDWidth;
    CGFloat introductionViewH = 20;
    self.introductionView = [[UIView alloc]initWithFrame:CGRectMake(introductionViewX, introductionViewY, introductionViewW, introductionViewH)];
    self.introductionView.backgroundColor =[UIColor getColorWithHexNumber:@"F1F1EE"];

    [self.scroll addSubview:self.introductionView];
    
}

-(void)setUpDedails
{
    
    CGFloat detailLblX = HJDHorizontalMargin;
    CGFloat detailLblY = CGRectGetMaxY(self.introductionView.frame) + HJDVerticalMargin/2;
    CGFloat detailLblW = HJDWidth;
    CGFloat detailLblH = 30;
    UILabel *detailLbl = [[UILabel alloc]initWithFrame:CGRectMake(detailLblX, detailLblY, detailLblW, detailLblH)];
    detailLbl.text = @"详情";
    detailLbl.textColor = [UIColor getColorWithHexNumber:@"323232"];
    detailLbl.font = [UIFont systemFontOfSize:15];
    [self.scroll addSubview:detailLbl];
    
    CGFloat detailviewX = HJDHorizontalMargin ;
    CGFloat detailviewY = CGRectGetMaxY(detailLbl.frame);
    CGFloat detailviewW = HJDWidth - HJDHorizontalMargin ;
    CGFloat detailviewH = 1;
    UIView *detailview = [[UIView alloc]initWithFrame:CGRectMake(detailviewX, detailviewY, detailviewW, detailviewH)];
    detailview.backgroundColor = [UIColor getColorWithHexNumber:@"F1F1EE"];
    [self.scroll addSubview:detailview];
    
    
    CGFloat lbloneX = HJDHorizontalMargin;
    CGFloat lbloneY = CGRectGetMaxY(detailview.frame)+ HJDVerticalMargin/2;
    CGFloat lbloneW = HJDWidth;
    CGFloat lbloneH = 20;
    UILabel *lblone = [[UILabel alloc]initWithFrame:CGRectMake(lbloneX, lbloneY, lbloneW, lbloneH)];
    lblone.text = @"中文名称：常州红房子医院";
    lblone.textColor = [UIColor grayColor];

    [self.scroll addSubview:lblone];
    
    CGFloat lbltwoX = HJDHorizontalMargin;
    CGFloat lbltwoY = CGRectGetMaxY(lblone.frame)+5;
    CGFloat lbltwoW = HJDWidth;
    CGFloat lbltwoH = 20;
    UILabel *lbltwo = [[UILabel alloc]initWithFrame:CGRectMake(lbltwoX, lbltwoY, lbltwoW, lbltwoH)];
    lbltwo.text = @"地理位置：常州市武进区常武北路2号";
    lbltwo.textColor = [UIColor grayColor];

    [self.scroll addSubview:lbltwo];
    
    CGFloat lblthreeX = HJDHorizontalMargin;
    CGFloat lblthreeY = CGRectGetMaxY(lbltwo.frame)+ 5;
    CGFloat lblthreeW = HJDWidth;
    CGFloat lblthreeH = 20;
    UILabel *lblthree = [[UILabel alloc]initWithFrame:CGRectMake(lblthreeX, lblthreeY, lblthreeW, lblthreeH)];
    lblthree.text = @"开放时间：08:00-20:30 节假日休息";
    lblthree.textColor = [UIColor grayColor];

    [self.scroll addSubview:lblthree];
    
    CGFloat lblfourX = HJDHorizontalMargin;
    CGFloat lblfourY = CGRectGetMaxY(lblthree.frame)+ HJDVerticalMargin/2;
    CGFloat lblfourW = HJDWidth;
    CGFloat lblfourH = 20;
    UILabel *lblfour = [[UILabel alloc]initWithFrame:CGRectMake(lblfourX, lblfourY, lblfourW, lblfourH)];
    lblfour.text = @"医院类型：妇产科";
    lblfour.textColor = [UIColor grayColor];

    [self.scroll addSubview:lblfour];
    
    CGFloat lblfiveX = HJDHorizontalMargin;
    CGFloat lblfiveY = CGRectGetMaxY(lblfour.frame)+ 5;
    CGFloat lblfiveW = HJDWidth;
    CGFloat lblfiveH = 20;
    UILabel *lblfive = [[UILabel alloc]initWithFrame:CGRectMake(lblfiveX, lblfiveY, lblfiveW, lblfiveH)];
    lblfive.text = @"医院等级：医保、农保";
    lblfive.textColor = [UIColor grayColor];
    [self.scroll addSubview:lblfive];
    
    CGFloat lblsixX = HJDHorizontalMargin;
    CGFloat lblsixY = CGRectGetMaxY(lblfive.frame)+5;
    CGFloat lblsixW = HJDWidth;
    CGFloat lblsixH = 20;
    UILabel *lblsix = [[UILabel alloc]initWithFrame:CGRectMake(lblsixX, lblsixY, lblsixW, lblsixH)];
    lblsix.text = @"所属地区：常州市武进区";
    lblsix.textColor = [UIColor grayColor];

    [self.scroll addSubview:lblsix];

    
}

-(void)phoneBtnClick
{
    HJDLog(@"电话");
}

-(void)btntitleClick
{
    HJDDetailViewController *detail = [[HJDDetailViewController alloc]init];
    HJDNavigationController *nav = [[HJDNavigationController alloc]initWithRootViewController:detail];
    [self presentViewController:nav animated:YES completion:nil];

}
@end
